<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript">
        //不全字符串
        let str1='x'.padStart(5,'ab');
        console.log(str1);  //'ababx'

        let str2='x'.padStart(4,'ab');
        console.log(str2);  //abax

        let str3='x'.padEnd(5,'ab');
        console.log(str3);  //xabab

        let str4='x'.padEnd(4,'ab');
        console.log(str4);  //xaba

        //消除空格
        const s=`   welcome    `;
        console.log(s.trim());  //"welcome"
        console.log(s.trimStart());//"welcome      "
        console.log(s.trimEnd());//"    welcome"

        //返回指定位置字符串
        const str='hello';
        console.log(str.charAt(1)); //"e"
        console.log(str.at(-1)); //"o"
    </script>
</body>
</html>